package com.zprmb.udzt;

import java.text.DecimalFormat;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
 * 智投宝转出成功
 * @author shenshao
 *
 */
public class DexterityoutSuccess extends QQActivity {
	private TextView tv_amount,tv_out_money,tv_shouxu;
	private Button btn_ok;
	private String shouxu;
	double actual;
	private RelativeLayout rl_back;
	private ImageView img_join;
	private DecimalFormat df = new DecimalFormat("###0.00");
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lingcunout_success);
		 BbtApplication.getInstance().addActvity(this);
		tv_amount=(TextView)findViewById(R.id.arrive);
		
		tv_shouxu=(TextView)findViewById(R.id.fee_money);
		tv_out_money=(TextView)findViewById(R.id.out_money);
		btn_ok=(Button)findViewById(R.id.btn_ok);
		img_join=(ImageView)findViewById(R.id.join_qq_group);
		shouxu=getIntent().getStringExtra("fee");
		actual=getIntent().getDoubleExtra("actual", 0);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		img_join.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				joinQQGroup("dYKhVAU5hwpBBFGWW0PPRgOLDi9-xdcd");
			}
		});
		rl_back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		btn_ok.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent=new Intent(DexterityoutSuccess.this,MainActivity.class);
				startActivity(intent);
			}
		});
		tv_out_money.setText("成功申请转出"+df.format(Double.parseDouble(getIntent().getStringExtra("amount")))+"元");
		tv_amount.setText("应到账"+df.format(actual));
		tv_shouxu.setText("手续费"+shouxu);
		
	}
	
	public boolean joinQQGroup(String key) {  
	    Intent intent = new Intent();  
	    intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));  
	   // 此Flag可根据具体产品需要自定义，如设置，则在加群界面按返回，返回手Q主界面，不设置，按返回会返回到呼起产品界面    //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)  
	    try {  
	        startActivity(intent);  
	        return true;  
	    } catch (Exception e) {  
	        // 未安装手Q或安装的版本不支持  
	        return false;  
	    }  
	} 
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
}
